﻿using Reborn.Net.Http.Drive;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reborn.Net.Http
{
    public class HttpClientX
    {
        Drive.Drive _drive = null;

        public HttpClientX(Drive.Drive drive)
        {
            _drive = drive;
        }


        /// <summary>
        /// Get异步请求
        /// </summary>
        /// <returns></returns>
        public Task<Response> GetAsync(string url, Request request = null)
        {
            return _drive.GetAsync(url, request);
        }

        /// <summary>
        /// Get请求
        /// </summary>
        /// <returns></returns>
        public Response Get(string url, Request request = null)
        {
            return _drive.Get(url, request);
        }


        /// <summary>
        /// 获取字节
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public byte[] GetByte(string url)
        {
            return _drive.GetByte(url);
        }


        /// <summary>
        /// 异步获取字节
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public Task<byte[]> GetByteAsync(string url)
        {
            return _drive.GetByteAsync(url);
        }

        /// <summary>
        /// POST请求
        /// </summary>
        /// <returns></returns>
        public Response Post(string url, string token, Request request = null)
        {
            return _drive.Post(url, token, request);
        }


        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="url"></param>
        /// <param name=""></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public Response Post(string url, Dictionary<string, string> dicArgs, Request request = null)
        {
            return _drive.Post(url, dicArgs, request);
        }

        /// <summary>
        /// POST异步请求
        /// </summary>
        /// <returns></returns>
        public Task<Response> PostAsync(string url, string token, Request request = null)
        {
            return _drive.PostAsync(url, token, request);
        }

        /// <summary>
        /// POST异步请求
        /// </summary>
        /// <returns></returns>
        public Task<Response> PostAsync(string url, Dictionary<string, string> dicArgs, Request request = null)
        {
            return _drive.PostAsync(url, dicArgs, request);
        }

        /// <summary>
        /// 请求JSON
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public Response PostJson(string url, JToken postArgs, Request request = null)
        {
            return _drive.PostJson(url, postArgs, request);
        }



        public Task<Response> PostJsonAsync(string url, JToken postArgs, Request request = null)
        {
            return _drive.PostJsonAsync(url, postArgs, request);
        }
    }
}
